package ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.service.factories.imp;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.devicecontroller.ProcessImageDated;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.persistence.model.Device;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.persistence.model.Field;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.service.FieldService;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.service.factories.FieldServiceFactory;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.service.imp.FieldServiceImp;
import ar.edu.utn.frsf.proyectofinal.sistemadecontrolmodbus.persistence.DeviceDAO;

@Component
public class FieldServiceFactoryImp implements FieldServiceFactory {

	@Autowired(required = true)
	private DeviceDAO deviceDAO;
	
	
	@Override
	public List<FieldService> create(List<Field> fields, Device device, ProcessImageDated image) {
		List<FieldService> ret = new ArrayList<FieldService>();
		for (Field field : fields) {
			ret.add(create(field,device,image));
		}
		return ret;
	}
	@Override
	public FieldService create(Field field, Device device, ProcessImageDated image) {
		FieldServiceImp nserv = new FieldServiceImp();
		nserv.setField(field);
		nserv.setDeviceDAO(deviceDAO);
		nserv.setDevice(device);
		nserv.setImage(image);
		return nserv;
	}
	/**
	 * @return the devicedao
	 */
	public DeviceDAO getDeviceDAO() {
		return deviceDAO;
	}
	/**
	 * @param devicedao the devicedao to set
	 */
	public void setDeviceDAO(DeviceDAO deviceDAO) {
		this.deviceDAO = deviceDAO;
	}
	

}
